<?php

namespace App\Http\Controllers;

use App\Mail\ContactMail;
use Illuminate\Support\Facades\Mail;
use App\Http\Requests\ContactMeRequest;


class ContactController extends Controller
{
    //
    public function showForm()
    {
        return view('blog.contact');
    }

    /**
     * 发送消息体
     *
     * @param ContactMeRquest $request
     * @return void
     */
    public function sendContactInfo(ContactMeRequest $request)
    {
        $data = $request->only('name', 'email', 'phone');
        $data['messageLines'] = explode("\n", $request->get('message'));

        // 推送到同步发送邮件
        // Mail::to($data['email'])->send(new ContactMail($data));

        // 推送到队列任务
        Mail::to($data['email'])->queue(new ContactMail($data));

        return back()->with("success", "消息已发送,感谢您的反馈");
    }

}
